package com.lcb.manager.repository;

import com.lcb.manager.entity.Scientific;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.sql.Date;

public interface ScientificRepository extends JpaRepository<Scientific, Integer> {

    @Query(value = "select * from scientific where year(`date`) = ?1 and month(`date`) = ?2 ",
            countQuery = "select count(*) from scientific where year(`date`) = ?1 and month(`date`) = ?2 ",
            nativeQuery = true)
    Page<Scientific> findByDateOrderByDateAsc(String year, String month, Pageable pageable);

    Page<Scientific> findByOrderByDateAsc(Pageable pageable);
}
